home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
By Popular Request 2.0
/
By Popular Request 2.0 (Arsenal Computer).ISO
/
amiga_1
/
ace_prgs.lha
/
GAMES
/
CARDMAST.LHA
/
cardmaster.b
< prev
next >
Wrap
Text File
|
1994-12-11
|
8KB
|
358 lines
rem *** CardMaster ***
OPTION O+
dim set$(7)
dim rarity$(13)
dim clor$(8)
dim type$(7)
dim freq(13)
dim unifreq(13)
dim colcount(6,8)
dim unicount(6,8)
dim setcount(6)
dim unisetct(6)
CONST NULL = 0&
window 1,"CardMASTER 1.2⌐ by Rich Allen",(0,0)-(360,181),22
FONT "topaz",8
struct card
shortint number
shortint set
shortint rarity
shortint ccolor
shortint ctype
string cname
address nextc
address prevc
end struct
declare struct card *head,*new.card,*curr,*temp
sub make.card&
make.card& = Alloc(sizeof(card),2)
end sub
head = make.card&
if head = NULL then
print "Head card can't be allocated!"
stop
end if
head->number = NULL
head->set = NULL
head->rarity = NULL
head->ccolor = NULL
head->ctype = NULL
head->cname = ""
head->nextc = NULL
head->prevc = NULL
curr = head
temp = head
for loop = 1 to 7
read set$(loop)
next
for loop = 1 to 13
read rarity$(loop)
next
for loop = 1 to 8
read clor$(loop)
next
for loop = 1 to 7
read type$(loop)
next
data Revised,"The Dark",Antiquities,"Arabian Nights",Legends,Unlimited,"Fallen Empires"
data Land,"Common",Uncommon,Rare,Common1,Common2,Common3,Common4,Common5
data Uncommon1,Uncommon2,Uncommon3,Uncommon4
data Land,Artifact,Black,Blue,Green,Red,White,Gold
data Enchantment,Instant,Interrupt,Sorcery,Summon,Artifact,"Artifact Creature"
cls
gadget 1,ON ,"QUIT",(80,104)-(130,128),BUTTON
gadget 2,OFF,"ADD CARD",(3,96)-(75,115),BUTTON
gadget 3,OFF,"SUB CARD",(3,118)-(75,137),BUTTON
gadget 4,OFF,"NEXT CARD",(135,96)-(225,115),BUTTON
gadget 5,OFF,"PREV CARD",(135,118)-(225,137),BUTTON
gadget 6,ON ,"LOAD DATABASE",(232,30)-(349,49),BUTTON
gadget 7,OFF,"SAVE DATABASE",(232,52)-(349,71),BUTTON
gadget 8,OFF,"COUNT TO PRT:",(232,74)-(349,93),BUTTON
gadget 9,OFF,"COUNT TO DISK",(232,96)-(349,115),BUTTON
gadget 10,OFF,"LIST TO PRT:",(232,118)-(349,137),BUTTON
gadget 11,OFF,"LIST TO DISK",(232,140)-(349,159),BUTTON
WHILE -1
gadget wait 0
gosub button_pushed
gosub display
WEND
button_pushed:
gad = gadget(1)
if gad = 1 then if MsgBox("Are you sure?","Yes","Nope") then quit
if gad = 2 and curr->number < 256 then curr->number = curr->number + 1
if gad = 3 and curr->number > 0 then curr->number = curr->number - 1
if gad = 4 then curr = curr->nextc
if gad = 5 then curr = curr->prevc
if gad = 6 then gosub loaddb
if gad = 7 then gosub savedb
if gad = 8 then
file$ = "PRT:"
gosub count
end if
if gad = 9 then
file$ = filebox$("Save COUNT to")
if file$ <> "" then gosub count
end if
if gad = 10 then
file$ = "PRT:"
gosub genlist
end if
if gad = 11 then
file$ = filebox$("Save LIST to")
if file$ <> "" then gosub genlist
end if
if gad = 20 then gosub search
return
display:
locate 2
print " Card : ";curr->cname;space$(30)
print
print " Color : ";clor$(curr->ccolor);" "
print " Rarity: ";rarity$(curr->rarity);" "
print " Type : ";type$(curr->ctype);space$(18-len(type$(curr->ctype)))
print " Set : ";set$(curr->set);" "
print
print " # of cards: ";curr->number;" "
return
loaddb:
file$ = filebox$("Load database")
if file$ <> "" then
window 2,,(50,100)-(300,150),0
FONT "topaz",8
cls
locate 2
print " Loading card data..."
open "I",1,file$
input #1,numcards
For loop = 1 to numcards
input #1,code$,card$
locate 2,22
print loop
new.card = make.card&
if new.card = NULL then
temp& = MsgBox("Out of memory!","OK")
close 1
window close 2
goto quit
end if
new.card->number = val("&H"+left$(code$,2))
new.card->ccolor = val(mid$(code$,3,1))
new.card->ctype = val(mid$(code$,4,1))
new.card->set = val(mid$(code$,5,1))
new.card->rarity = val("&H"+right$(code$,1))
new.card->cname = card$
new.card->nextc = NULL
curr->nextc = new.card
curr->prevc = temp
temp = curr
curr = curr->nextc
Next
curr->prevc = temp
temp = curr
curr = head->nextc
curr->prevc = temp
temp->nextc = curr
close 1
window close 2
end if
gadget 2,ON
gadget 3,ON
gadget 4,ON
gadget 5,ON
gadget 6,OFF
gadget 7,ON
gadget 8,ON
gadget 9,ON
gadget 10,ON
gadget 11,ON
gadget 20,ON,"Search for a card name",(8,144)-(230,161),STRING
return
savedb:
file$ = filebox$("Save database")
if file$ <> "" then
window 2,,(50,100)-(300,150),0
FONT "topaz",8
cls
locate 2
print " Saving card data..."
open "O",1,file$
write #1,numcards
temp = curr
curr = head->nextc
for loop = 1 to numcards
code$ = hex$(curr->number) + hex$(curr->ccolor) + hex$(curr->ctype)
code$ = code$ + hex$(curr->set) + hex$(curr->rarity)
if len(code$) = 5 then code$ = "0"+code$
write #1,code$,curr->cname
locate 2,22
print loop
curr = curr->nextc
next
close 1
window close 2
curr = temp
end if
return
count:
window 2,,(0,0)-(360,150),0
FONT "topaz",8
cls
temp = curr
curr = head->nextc
total = 0
unique = 0
for xloop = 1 to 6
for yloop = 1 to 8
colcount(xloop,yloop) = 0
unicount(xloop,yloop) = 0
next
setcount(xloop) = 0
next
for loop = 1 to 13
freq(loop) = 0
unifreq(loop) = 0
next
locate 2
print " Counting cards..."
for loop = 1 to numcards
if curr->number <> 0 then
total = total + curr->number
++unique
freq(curr->rarity) = freq(curr->rarity) + curr->number
unifreq(curr->rarity) = unifreq(curr->rarity) + 1
colcount(curr->set,curr->ccolor) = colcount(curr->set,curr->ccolor) + curr->number
unicount(curr->set,curr->ccolor) = colcount(curr->set,curr->ccolor) + 1
setcount(curr->set) = setcount(curr->set) + curr->number
unisetct(curr->set) = unisetct(curr->set) + 1
end if
locate 2,19
print loop
curr = curr->nextc
next
open "O",1,file$
print
print "Total cards (excluding basic lands) :";total
print #1,"Total cards (excluding basic lands) :";total
print "Total unique cards :";unique
print #1,"Total unique cards :";unique
print #1,chr$(13)
for xloop = 1 to 6
if setcount(xloop) <> 0 then
for yloop = 1 to 8
if colcount(xloop,yloop) <> 0 then
print #1,"Total ";set$(xloop);" ";clor$(yloop);" cards";
print #1,space$(9-len(clor$(yloop)));":";colcount(xloop,yloop)
print #1,"Unique ";set$(xloop);" ";clor$(yloop);" cards";
print #1,space$(9-len(clor$(yloop)));":";unicount(xloop,yloop)
end if
next
print #1,"Total ";set$(xloop);" cards: ";setcount(xloop)
print #1,"Unique ";set$(xloop);" cards: ";unisetct(xloop)
print #1,chr$(13)
end if
next
for loop = 2 to 13
if freq(loop) <> 0 then
print "Total "rarity$(loop);" cards";space$(16-len(rarity$(loop)));":";freq(loop)
print #1,"Total "rarity$(loop);" cards";space$(16-len(rarity$(loop)));":";freq(loop)
print #1,"Unique "rarity$(loop);" cards";space$(15-len(rarity$(loop)));":";unifreq(loop)
end if
next
gadget 50,ON,"OK",(113,125)-(145,140),BUTTON
gadget wait 50
gadget close 50
close 1
window close 2
curr = temp
return
genlist:
window 2,,(50,100)-(250,150),0
FONT "topaz",8
cls
locate 2
temp = curr
curr = head->nextc
open "O",1,file$
print "Saving list"
for loop = 1 to numcards
if curr->number <> 0 then
print #1,curr->number;chr$(9);
print #1,curr->cname;space$(35-len(curr->cname));
print #1,clor$(curr->ccolor);space$(10-len(clor$(curr->ccolor)));
print #1,set$(curr->set);space$(10-len(set$(curr->set)));
print #1,rarity$(curr->rarity)
end if
locate 2,15
print loop
curr = curr->nextc
next
close 1
window close 2
curr = temp
return
search:
srch$=CSTR(gadget(2))
slen = len(srch$)
snf = 0
temp = curr
curr = curr->nextc
while (left$(curr->cname,slen) <> srch$) and snf<>1
curr = curr->nextc
if curr = temp then
snf = 1
beep
end if
wend
gosub display
return
quit:
gadget close 1
window close 1
end